/** 
 * Project Name: platform
 * File Name:UserInfoWidget.js 
 * Package Name:  webapp/app/view/protal/module/systemManager/sources/attachments
 * Author :  JasonWu (15909910367@163.com)
 * Date:  2021年4月15日 
 * Copyright (c) 202o, 15909910367@163.com All Rights Reserved. 
 * 
 */
Ext.define('Jason.view.protal.module.systemManager.sources.attachments.MainView', {
    extend: 'Wys.basic.BaseView',
    xtype: 'sysAttachmentView',
    itemId: 'sysAttachmentView',
    requires: [
        'Jason.store.protal.module.systemManager.sources.attachments.Store',
        'Jason.view.protal.module.systemManager.sources.attachments.MainViewModel'
    ],
    viewModel: { type: 'attachmentsViewModel' },
    dockedItems: [{
        xtype: 'pagingtoolbar',
        bind: '{attachmentsStore}',
        enabledMoreOpt: true,
        dock: 'bottom'
    }, {
        xtype: 'toolbar', dock: 'top',
        items: [{
            xtype: 'gridsearchfield',
            paramName: 'qqfilename'
        }, '->', {
            xtype: 'refresh', viewItemId: '#sysAttachmentView',
            rightCode: 'FJGL'
        }]
    }],
    selType: null,
    bind: '{attachmentsStore}',
    listeners: {
        cellclick: function (table, td, cellIndex, record) {
            if (cellIndex != 3)
                return;
            var imgArray = new Array();
            var temp = record.get('filepath').split('|');
            EUtil.RS({
                url: reqUrl.sys.attachments.priview + '/' + temp[0] + "/" + temp[1],
                method: 'GET',
                callback: function (resp) {
                    if (resp.success) {
                        imgArray.push({
                            thumbnailsPath: record.get('filepath') || '',
                            sourcePath: resp.data || '',
                            title: record.get('qqfilename'),
                            filename: record.get('qqfilename'),
                            isRemove: false,
                            recordkey: record.get('qquuid')
                        });
                        Ext.create('Wys.view.AttachmentWin', {
                            type: 2,
                            imgArray: imgArray
                        }).show();
                    } else {
                        EUtil.showWarning('文件【' + record.get('qqfilename') + '】预览失败');
                    }
                }
            });
        }
    },
    columns: [
        {
            text: '文件名', dataIndex: 'qqfilename', flex: 2, renderer: function (v, m) {
                m.style = "font-weight:bold;";
                return '<i class="' + CUtil.getFileTypeIconCls(CUtil.getFileSuffix(v)) + ' color-blue"></i>' + v;
            }
        },
        {
            text: '文件大小', dataIndex: 'qqtotalfilesize', width: 100, align: 'right', renderer: function (v, m, r) {
                return CUtil.getFileSize(v);
            }
        },
        { text: '文件路径', dataIndex: 'filepath', flex: 8 },
        { text: '创建人', dataIndex: 'creater', width: 80 },
        { text: '创建日期', dataIndex: 'createtime', width: 135, xtype: 'datecolumn', format: 'Y-m-d H:i' }
    ]
});